﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Media;

namespace WoodRobotics.Weather.Assets
{
    public class ContentToMarginConverter : IValueConverter
    {
        #region IValueConverter Members
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return new Thickness(-.60, 0, -((ContentPresenter)value).ActualHeight, 0);
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
        #endregion IValueConverter Members
    }
    public class ContentToPathConverter : IValueConverter
    {
        #region IValueConverter Members
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {

            var ps = new PathSegmentCollection(4);

            if (value == DependencyProperty.UnsetValue)
            {

                double h = 18.5;
                double w = 25.0;

                ps.Add(new LineSegment(new Point(1, 0.7 * h), true));
                ps.Add(new BezierSegment(new Point(1, 0.9 * h), new Point(0.1 * h, h), new Point(0.3 * h, h), true));
                ps.Add(new LineSegment(new Point(w, h), true));
                ps.Add(new BezierSegment(new Point(w + 0.6 * h, h), new Point(w + h, 0), new Point(w + h * 1.3, 1), true));

            }
            else
            {

                ContentPresenter cp = (ContentPresenter)value;
                double h = 18.5;
                double w = cp.ActualWidth + 5.0;

                ps.Add(new LineSegment(new Point(1, 0.7 * h), true));
                ps.Add(new BezierSegment(new Point(1, 0.9 * h), new Point(0.1 * h, h), new Point(0.3 * h, h), true));
                ps.Add(new LineSegment(new Point(w, h), true));
                ps.Add(new BezierSegment(new Point(w + 0.6 * h, h), new Point(w + h, 0), new Point(w + h * 1.3, 1), true));

            }

            PathFigure figure = new PathFigure(new Point(1, 0), ps, false);
            PathGeometry geometry = new PathGeometry();
            geometry.Figures.Add(figure);

            return geometry;

        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
        #endregion IValueConverter Members
    }
}
